package com.scuec.groupfive.mapper;
import com.scuec.groupfive.entity.SystemSetting_six;
import org.apache.ibatis.annotations.Mapper;
import org.apache.ibatis.annotations.Select;
import org.apache.ibatis.annotations.Update;

@Mapper
public interface SystemSettingMapper_six {

    @Select("SELECT " +
            "setting_id AS settingId, " +
            "setting_key AS settingKey, " +
            "setting_value AS settingValue, " +
            "system_name AS systemName, " +
            "system_logo AS systemLogo, " + // Logo字段
            "system_description AS systemDescription, " +
            "customer_service_email AS customerServiceEmail, " +
            "customer_service_phone AS customerServicePhone, " +
            "copyright_info AS copyrightInfo, " +
            "current_version AS currentVersion, " +
            "created_at AS createdAt, " +
            "updated_at AS updatedAt " +
            "FROM system_settings ORDER BY setting_id DESC LIMIT 1")
    SystemSetting_six getLatestSystemSetting();

    @Update("UPDATE system_settings SET " +
            "setting_key = #{settingKey}, " +
            "setting_value = #{settingValue}, " +
            "system_name = #{systemName}, " +
            "system_logo = #{systemLogo}, " + // Logo字段
            "system_description = #{systemDescription}, " +
            "customer_service_email = #{customerServiceEmail}, " +
            "customer_service_phone = #{customerServicePhone}, " +
            "copyright_info = #{copyrightInfo}, " +
            "current_version = #{currentVersion}, " +
            "updated_at = NOW() " +
            "WHERE setting_id = #{settingId}")
    int updateSystemSetting(SystemSetting_six systemSetting);
}